/****** Object:  Table [dbo].[DocTemplateTemp]    Script Date: 05/13/2011 16:14:47 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[DocTemplateTemp](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](1000) NOT NULL,
	[OrderId] [int] NULL,
	[CreateDate] [datetime] NOT NULL,
	[Version] [int] NULL,
	[ParentId] [int] NULL,
 CONSTRAINT [PK_DocTemplateTemp] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[DocTemplateTemp]  WITH CHECK ADD  CONSTRAINT [FK_DocTemplateTemp_DocTemplateTemp] FOREIGN KEY([ParentId])
REFERENCES [dbo].[DocTemplateTemp] ([Id])
GO

ALTER TABLE [dbo].[DocTemplateTemp] CHECK CONSTRAINT [FK_DocTemplateTemp_DocTemplateTemp]
GO

ALTER TABLE [dbo].[DocTemplateTemp]  WITH CHECK ADD  CONSTRAINT [FK_DocTemplateTemp_Order] FOREIGN KEY([OrderId])
REFERENCES [dbo].[Order] ([Id])
ON UPDATE CASCADE
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[DocTemplateTemp] CHECK CONSTRAINT [FK_DocTemplateTemp_Order]
GO


